<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style type="text/css">
        .aui-list-item.wechat-top {
            background-color: #f3f3f7;
        }
        .aui-list .wechat-avatar {
            width:3rem;
        }
        .wechat-avatar .aui-row-padded {
            background-color: #dddee0;
            padding: 0.1rem;
            border-radius: 0.2rem;
            margin-left: -0.05rem;
            margin-right: -0.05rem;
        }
        .wechat-avatar .aui-row-padded [class*=aui-col-xs-] {
            padding: 0.05rem;
        }
        .wechat-avatar,
        .wechat-avatar > img {
            border-radius:0.2rem;
        }
    </style>
</head>
<body>
    <div class="aui-content aui-margin-b-15  aui-margin-t-10">
        <ul class="aui-list aui-media-list" id="group_id">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/zepto.min.js" ></script>
<script type="text/javascript" src="../script/api.js" ></script>
<script type="text/javascript">
apiready = function(){
    api.sendEvent({
        name:'getDiscussion',
        extra:{
        }
    });

    var username = $api.getStorage('username');
    api.ajax({
        url: ServeUrl + "m=Index&a=groupList",
        method: 'post',
        data: {
            values: {
                username: username
            }
        }
    }, function(ret, err) {
        if (ret) {
            var html = "";
            if(ret.data!=""&&ret.data!=null){
              for (var i = 0; i < ret.data.length; i++) {
                  html+='<li class="aui-list-item aui-list-item-middle" onclick="openWin('+"'send_groupmsg','"+ret.data[i].groupId+"','"+ret.data[i].groupName+"'"+')">'
                  html+='<div class="aui-media-list-item-inner">'
                  html+='<div class="aui-list-item-media wechat-avatar">'
                  //html+='<div class="aui-dot"></div>'
                  if(ret.data[i].img_file==null||ret.data[i].img_file==""){
                      html+='<img src="../image/users.png" />'
                  }else {
                      html+='<img src="'+ServeIp+'include/data/headImg/'+ret.data[i].img_file+'" />'
                  }
                  html+='</div>'
                  html+='  <div class="aui-list-item-inner">'
                  html+='<div class="aui-list-item-text">'
                  html+='<div class="aui-list-item-title">'+ret.data[i].groupName+'</div>'
                  html+='  </div>'
                  html+='</div>'
                  html+='</div>'
                  html+='</li>';
              }
              $("#group_id").append(html);
            }
        } else {
            api.alert({ msg: JSON.stringify(err) });
        }
    });

}

function openWin(name,targetId,groupName) {
    //个人页进入会话页面，获取历史消息
    $api.setStorage('historyMessages', '');
  //  alert($api.getStorage('personal_sent_time'));
    api.openWin({
        name: name,
        url: name+'_win.html',
        pageParam: {
            targetId:targetId,
            username:groupName,
            conversationType:'DISCUSSION'
        },
    });
}
</script>
</html>
